/*
 * Amkai Enterprise (AE) 
 * Copyright 2004-2006 by Amkai(TM), Inc.
 * www.amkai.com
 * 
 * Project: webservice
 * Package: com.amkai.aes.webservice.binary.objecthandler.organization
 * File: EnterpriseTreeHandler.java
 * Created: Jul 22, 2011 6:08:18 PM
 * Author: Miskolczi Peter 
 * 
 */
package com.amkai.aes.webservice.binary.objecthandler.organization;

import java.io.Serializable;

import com.amkai.aes.aescommon.service.binary.job.organization.EnterpriseTreeJob;
import com.amkai.aes.aescommon.service.result.organization.EnterpriseTreeResult;
import com.amkai.aes.server.organization.EnterpriseTreeManager;
import com.amkai.aes.webservice.binary.JobObjectHandler;
import com.amkai.common.extensions.hibernate.config.SiteManager;
import com.amkai.common.extensions.hibernate.config.manager.SessionManager;

/**
 * EnterpriseTreeHandler
 * @author Miskolczi Peter
 * Description:
 *
 */
public class EnterpriseTreeHandler implements JobObjectHandler<EnterpriseTreeJob, Serializable, EnterpriseTreeResult> {

	@Override
	public EnterpriseTreeResult process(EnterpriseTreeJob job,
			Serializable object) throws Exception {
		EnterpriseTreeResult result = new EnterpriseTreeResult();
		SessionManager sm = SiteManager.Start();
		try {
			EnterpriseTreeManager etm = new EnterpriseTreeManager(sm);
			result.nodes = etm.getAllNodes();
		} finally {
			sm.closeSession();
		}
		return result;
	}

}
